<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.JSONArray, org.json.JSONException, org.json.JSONObject, br.com.seuimovelnamao.model.Endereco, java.util.List" %>
<%
try {
    JSONArray array = new JSONArray();
    
    JSONObject jsonOne;

    Endereco endereco = (Endereco)request.getAttribute("endereco");
    
   	jsonOne = new JSONObject();

   	if(endereco != null){
	   	jsonOne.put("id", endereco.getId());
	   	jsonOne.put("endereco", endereco.getNomeCompleto());
	   	jsonOne.put("bairro", endereco.getBairro().getNome());
	   	jsonOne.put("cidade", endereco.getCidade().getNome());
	   	jsonOne.put("estado", endereco.getEstado().getNome());
   	}
    
    array.put(jsonOne);
    
    out.println(array);
                    
} catch (JSONException e) {
    e.printStackTrace();
}
%>